<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Foreach()</title>
  </head>
  <body>
    <h1>1</h1>
    <h1>2</h1>
    <h1>3</h1>
    <h1>4</h1>
    <h1>5</h1>
    <script>
      let elements = document.querySelectorAll(`h1`)

      elements.forEach(function (elem) {
        console.log(elem.innerHTML)
      })
    </script>
  </body>
</html>
